package com.maxjay.system.web.tag;

import java.io.Writer;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.lang.StringUtils;

import com.maxjay.common.exception.ERR;
import com.maxjay.common.exception.GeneException;
import com.maxjay.common.util.date.DateUtil;

public class DateFormatTag extends BodyTagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String value;

	@Override
	public int doStartTag() throws JspException {
		try {
			Writer writer = this.pageContext.getOut();
			if(StringUtils.isNotBlank(value)) {
				String formatDate = DateUtil.getDateStrByStr(value, DateUtil.LINK_DISPLAY_DATE_SPLIT);
				writer.write(formatDate);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw GeneException.getGeneException(ERR.ERROR_ERR_MSG, e);
		}
		return BodyTagSupport.EVAL_BODY_INCLUDE;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

}
